﻿@{
    Layout = null;
    var StartDate = ViewBag.StartDate;

}
@model DotNet.JCore.Entity.ManualReg
@using DotNet.Web;
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
    <title>西安市班线客运安全管理系统</title>
    <link href="~/www/css/style.css" rel="stylesheet" />
    <script src="~/www/js/layer_mobile/layer.js"></script>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
</head>
<body>
    <a class="homeLinks" href="@Url.Action("home","M_login")">返回主页</a>
    <div class="djcCen">
        <div class="djcCenHea"><span></span>人工稽查</div>
        <div class="djcCenFor">
            @*<form id="form1" method="post">
                    <input type="text" name="CarNO" value="" class="djcCFTxt"  placeholder="请输入车牌号查询" />
                    <input type="submit" value="搜索" class="djcCFBut" />
                </form>*@
        </div>
        <div class="djcCenTab" style="border-bottom:none;">
            <form id="myform">

                @Html.AntiForgeryToken()
                @Html.MarkCreate()
                @*@Html.HiddenFor(p => p.Id = "")
                    @Html.HiddenFor(p => p.Id)*@
                <div class="alert alert-danger fxhide"></div>
                <table class="djcCTDri">
                    <tr>
                        <td><span style="color:#F00"> * </span>车牌号</td>
                        <td>
                            <input type="text" class="djcCTCarTxt"
                                   id="CarNumber"
                                   name="@nameof(Model.CarNumber)" value="@Model.CarNumber"
                                   autocomplete="off" />
                            <input type="hidden" id="id" name="@nameof(Model.Id)" value="@Model.Id" />
                        </td>
                        <td><span style="color:#F00"> * </span>实载乘客</td>
                        <td>
                            <input class="djcCTCarTxt"
                                   id="ExitNumber"
                                   name="@nameof(Model.ExitNumber)" value="@Model.ExitNumber"
                                   data-validate="maxlength: 50"
                                   type="text" autocomplete="off" />
                        </td>
                    </tr>
                    <tr>
                        <td>售票数</td>
                        <td>
                            <input class="djcCTCarTxt"
                                   id="PassengerNumber"
                                   name="@nameof(Model.PassengerNumber)"
                                   value="@Model.PassengerNumber"
                                   type="text" autocomplete="off" />
                        </td>
                        <td>客运站</td>
                        <td>
                            <select class="djcCTCarSel"
                                    id="Station"
                                    name="@nameof(Model.Station)"
                                    data-text-field="StationName"
                                    data-width="165">
                                <option></option>
                                @Html.StationCategoryOption(Model.Station)
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>司机姓名</td>
                        <td>
                            <input class="djcCTCarTxt" id="DriverName" name="@nameof(Model.DriverName)" value="@Model.DriverName"
                                   data-validate="maxlength: 50"
                                   type="text" autocomplete="off" />
                        </td>
                        <td>司机电话</td>
                        <td>
                            <input class="djcCTCarTxt" id="DriverPhone" name="@nameof(Model.DriverPhone)" value="@Model.DriverPhone"
                                   data-validate="maxlength: 50"
                                   type="text" autocomplete="off" />
                        </td>
                    </tr>
                    <tr>
                        <td>线路</td>
                        <td>
                            <input class="djcCTCarTxt" id="Line" name="@nameof(Model.Line)" value="@Model.Line"
                                   data-validate="maxlength: 50"
                                   type="text" autocomplete="off" />
                        </td>
                        <td>运输企业</td>
                        <td>
                            <input class="djcCTCarTxt" id="Corp" name="@nameof(Model.Corp)" value="@Model.Corp"
                                   data-validate="maxlength: 200"
                                   type="text" autocomplete="off" />
                        </td>
                    </tr>
                    <tr>
                        <td>稽查状态</td>
                        <td>
                            <select class="form-control uiselect checkstatus djcCTCarSel" id="CheckStatus" name="@nameof(Model.CheckStatus)"
                                    data-text-field="CheckStatusName">
                                @Html.CheckStatusCategoryOption(Model.CheckStatus.ToString())
                            </select>
                        </td>
                        <td>稽查点</td>
                        <td>
                            <select class="djcCTCarSel"
                                    id="Point"
                                    name="@nameof(Model.PointId)"
                                    data-text-field="PointName">
                                @Html.CheckPointsCategoryOption(Model.PointId)
                            </select>
                        </td>
                    </tr>
                    <tr id="OffenceRow" style="display:none;">
                        <td>违规内容</td>
                        <td>
                            <select class="djcCTCarSel" id="Offence" name="@nameof(Model.OffenceId)"
                                    data-text-field="OffenceName">
                                @Html.OffenceIdCategoryOption(Model.OffenceId)
                            </select>
                        </td>
                        <td>处理结果</td>
                        <td>
                            <select class="djcCTCarSel" name="@nameof(Model.ProcessStatus)"
                                    data-text-field="ProcessStatusName">
                                @Html.ProcessStatusCategoryOption(Model.ProcessStatus)
                            </select>
                        </td>
                    </tr>

                    <tr><td>备注</td><td colspan="3"><textarea class="djcCTCarTar" name="@nameof(Model.Note)" rows="3">@Model.Note</textarea></td></tr>
                </table>
                <div class="djcCenTabBc">
                    <button class="djcCFBut" onclick="return SubmitData()">
                        <i class="fa fa-search"></i>保存
                    </button>
                    <a href="@Url.Action("Index","M_SyncCarExitStation")" class="qxBut">取消</a>
                </div>
            </form>
        </div>
    </div>
</body>
</html>
@Html.LocalImport("~/www/js/WdatePicker.js")
@Html.CdnImport("~/lib/jquery/jquery.js")

<script>
    function SubmitData() {
        var id = $("#id").val();
        var BusCode = $("#CarNumber").val();//车牌号
        var OutNum = $("#PassengerNumber").val();//售票人数
        var SaleCount = $("#ExitNumber").val();//实载乘客人数
        var OwnerStation = $("#Station").val();//所属客运站
        var UserName = $("#DriverName").val();//驾驶员姓名
        var UserPhone = $("#DriverPhone").val();//驾驶员电话
        var LineName = $("#Line").val();//线路
        var OwnerCompName = $("#Corp").val();//运输企业
        var CheckStatus = $("#CheckStatus").val();//稽查状态
        var PointID = $("#Point").val();//稽查点ID
        var PointName = $("#Point").find("option:selected").text();//稽查点名称
        var OffenceID = $("#Offence").val();//违规内容ID
        var OffenceName = $("#Offence").find("option:selected").text();//违规内容
        if (BusCode == null || BusCode.length <= 0) {
            layer.open({ content: "请输入车牌号！", btn: "确定" });
            return false;
        }
        if (BusCode.search(/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/) == -1) {
            layer.open({ content: "请输入正确的车牌号码！", btn: "确定" });
            return false;
        }
        if (SaleCount == null || SaleCount.length <= 0) {

            layer.open({ content: "请输入实载乘客人数！", btn: "确定" });
            return false;
        }

        $.ajax({
            type: "POST",
            url: "/M_ManualReg/Save",
            data: {
                ID: id, CarNO: BusCode, PassengerNumber: OutNum, ExitNumber: SaleCount,
                Station: OwnerStation, DriverName: UserName, DriverPhone: UserPhone,
                Line: LineName, Corp: OwnerCompName, CheckStatus: CheckStatus, PointID: PointID,
                PointName: PointName, OffenceID: OffenceID, OffenceName: OffenceName,
                __RequestVerificationToken: $('input[name=__RequestVerificationToken]').val()
            },
            datatype: "json",
            success: function (result) {
                if (result.success) {
                    layer.open({
                        content: '人工登记成功！'
                        , btn: ['继续登记', '返回主页']
                        , yes: function (index, layero) {
                            window.location.reload();//刷新当前页面.
                        }
                        , no: function (index, layero) {
                            //按钮【按钮一】的回调
                            window.location = '@Url.Action("home", "M_login")';
                        }
                        , cancel: function () {
                            //右上角关闭回调
                            return false;// 开启该代码可禁止点击该按钮关闭
                        }
                    });
                }
            }
        });
        return false;

    }
</script>

<script>
    $('.checkstatus').on("change", function () {
        showcheckstatus();
    });
    function showcheckstatus() {
        if ($('.checkstatus').val() == '1') { //违规
            $('#OffenceRow').show();
        }
        else {
            $('#OffenceRow').hide();
        }
    }

    showcheckstatus();
</script>

<script type="text/javascript">
    function SearchData() {
        var busCode = document.getElementById("CarNO").value;
        $.ajax({
            type: "POST",
            url: "M_SyncCarExitStation/Grid",
            data: { CarNO: busCode},
            datatype: "json",
            timeOut: 15000,
            success: function (result) {
                if (data.success)
                {
                    window.location = " @Url.Action("Index", "M_SyncCarExitStation")";
                }
            }
        });
    }
</script>
